<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>添加商品信息</title>
    <style>
        body {
            font-family: -apple-system, sans-serif;
            background-color: #f4f4f8;
            margin: 0;
            padding: 20px;
            display: flex;
            justify-content: center;
        }

        .container {
            width: 100%;
            max-width: 600px;
            background: #fff;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            color: #333;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #555;
        }

        input[type="text"], select, textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 1em;
            box-sizing: border-box;
        }

        textarea {
            min-height: 150px;
            resize: vertical;
        }

        button {
            width: 100%;
            padding: 12px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 1.1em;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        button:hover {
            background-color: #0056b3;
        }

        .nav-link {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #007bff;
            text-decoration: none;
        }

        .flash-messages {
            list-style: none;
            padding: 0;
            margin-bottom: 20px;
        }

        .flash-messages li {
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 10px;
        }

        .flash-success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .flash-error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>添加商品知识</h1>

    <!-- Flash 消息显示区域 -->
    {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
    <ul class="flash-messages">
        {% for category, message in messages %}
        <li class="flash-{{ category }}">{{ message }}</li>
        {% endfor %}
    </ul>
    {% endif %}
    {% endwith %}

    <form method="POST" action="{{ url_for('add_product') }}">
        <div class="form-group">
            <label for="name">商品名称</label>
            <input type="text" id="name" name="name" required>
        </div>
        <div class="form-group">
            <label for="category">商品分类</label>
            <select id="category" name="category" required>
                <option value="laptop">笔记本</option>
                <option value="keyboard">键盘</option>
                <option value="mouse">鼠标</option>
                <option value="general">通用</option>
            </select>
        </div>
        <div class="form-group">
            <label for="description">商品描述 (支持Markdown)</label>
            <textarea id="description" name="description" required
                      placeholder="输入详细的商品规格、特性、价格等..."></textarea>
        </div>
        <button type="submit">添加到知识库</button>
    </form>
    <a href="{{ url_for('manage_knowledge') }}" class="nav-link">返回知识库管理</a>
    <a href="{{ url_for('index') }}" class="nav-link">返回聊天机器人</a>
</div>
</body>
</html>